@using System.Globalization;
@model UserProfile
@{
    Layout = "~/Views/Shared/_Dashboard.cshtml";
    var _user = Membership.GetUser(Context.Profile.UserName);
    var _context = WebSiteContext.Current;
}
@*@UIHelper.ImageTitle(_user.GetDisplayName(),Model.Signature,_user.GetAvatar(48))*@
@section HeaderSection{
    <style type="text/css">
        .ui-widget-content a { color: inherit; }
    </style>
    <script type="text/javascript">
      function _preview() {
          var _gravatar = $("#UserProfile_Gravatar");
          if (_gravatar.val()) {
              $("#img_avatar").hide();
              $("#imgLoader").show();
              $.get("@Url.Action("GetGravatarUrl", "Account")", { email: _gravatar.val() }, function (_url) {
                  $("#img_avatar").attr("src", _url);
                  $("#img_avatar").show();
                  $("#imgLoader").hide();
              });
          }
          else {
              _gravatar.focus();
          }
      }
      
      function _default()
      {
          $("#UserProfile_Gravatar").val("@_user.Email");
          _preview();
      }
    </script>
}
@UIHelper.ImageTitle(Html.Global("RES_PROFILE"), "", Url.Content("~/content/images/icon_profile_48.gif"))
@using (Html.BeginForm())
{
    <table style="margin-top: 10px;">
        <tr>
            <td>
                <div class="d-avatar" style="overflow: hidden; width: 80px;">
                    <div id="imgLoader" style="display:none;height:80px;width:80px;background:url(@Url.Content("~/content/images/lightbox-ico-loading.gif")) no-repeat center center;">
                    </div>
                    <img src="@_user.GetAvatar()"  id="img_avatar" />
                    <div>@Model.UserName</div>
                </div>
            </td>
            <td style="padding-left: 5px; font-size: 120%;">
                <table>
                    <tr>
                        <td>@Html.Global("Profile_Gravatar_Tips")
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @Ajax.DnaFor().TextBox(m => m.Gravatar).Width(300).IconImageUrl(Url.Content("~/content/images/icon_gravatar_16.jpg")).GetHtml()
                            <br />
                            @Ajax.Dna().Button("btnAuto").ChangeType(ButtonTypes.LinkButton).LocText("Profile_Use_Registered_Mail").ImageIcons(Url.Content("~/content/images/icon_mail_16.png")).Click("_default();").GetHtml()
                        </td>
                        <td style="vertical-align: top;">
                            @Ajax.Dna().Button("btnPreviewAvatar").ChangeType(ButtonTypes.LinkButton).LocText("RES_PREVIEW").Click("_preview();").GetHtml()
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <p>
    </p>
    Ajax.Dna().Tabs()
      .Options(opts =>
      {
          opts.OnTabSelected = "if (ui.index==2) $(\"#Signature\").richtextbox(\"active\");";
          opts.Animations = new { opacity = "toggle", height = "toggle", width = "toggle" };
      })
      .Views(views =>
      {
          views.Add(Html.Global("RES_COMMON"))
              .Template(@<text>
    <table class="d-field-table">
        <tr>
            <td>@Html.Global("RES_PUBMAIL"):
            </td>
            <td>
                @(Ajax.DnaFor().TextBox(m => m.Email)
                                  .HtmlAttributes(new { tabIndex = 0 })
                                  .Width(250)
                                  .IconImageUrl(Url.Content("~/content/images/icon_mail_16.png"))
                                  .GetHtml()
                )
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_DisplayName">
                    @Html.Global("RES_USER_DISPLAYNAME"):</label>
            </td>
            <td>
                @(Ajax.DnaFor().TextBox(m => m.DisplayName)
                                  .Width(250)
                                  .IconImageUrl(Url.Content("~/content/images/icon_contact_16.gif"))
                                  .GetHtml()
                )
            </td>
        </tr>
        <tr>
            <td>
                @Html.Global("RES_REALNAME"):
            </td>
            <td>
               <table>
               <tr><td>@Html.Global("RES_FRISTNAME")</td><td>@Html.Global("RES_LASTNAME")</td></tr>
               <tr><td>@(Ajax.DnaFor().TextBox(m => m.FirstName)
                                  .Width(100)
                                  .GetHtml()
                )</td><td>@(Ajax.DnaFor().TextBox(m => m.LastName)
                                  .Width(100)
                                  .GetHtml()
                )</td></tr>
               </table>
            </td>
        </tr>
        <tr>
            <td>
                @Html.Global("RES_GENDAR")
            </td>
            <td>
                <div>
                    <input type="radio" name="UserProfile.Gendar" value="M" id="UserProfile_Male" @if (!string.IsNullOrEmpty(Model.Gendar) && Model.Gendar.Equals("M"))
                                                                                                  { <text> checked="checked" </text>}/><label for="UserProfile_Male">@Html.Global("RES_MALE")</label>
                    <input type="radio" name="UserProfile.Gendar" value="F" id="UserProfile_Female" @if (!string.IsNullOrEmpty(Model.Gendar) && Model.Gendar.Equals("F"))
                                                                                                    { <text> checked="checked" </text>}/><label for="UserProfile_Female">@Html.Global("RES_FEMALE")</label>
                    <input type="radio" name="UserProfile.Gendar" value="P" id="UserProfile_Private" @if (string.IsNullOrEmpty(Model.Gendar) || Model.Gendar.Equals("P"))
                                                                                                     { <text> checked="checked" </text>} /><label for="UserProfile_Private">@Html.Global("RES_PRIVATE")</label>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_Birthday">
                    @Html.Global("RES_BIRTHDAY"):</label>
            </td>
            <td>
                @(Ajax.Dna().DatePicker("UserProfile.Birthday")
                           .Options(opts =>
                           {
                               opts.AllowChangeMonth = true;
                               opts.AllowChangeYear = true;
                           })
                           .Value(Model.Birthday)
                           .GetHtml()
                )
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_Language">
                    @Html.Global("RES_LANGUAGE"):</label>
            </td>
            <td>
                @(Ajax.DnaFor().ComboBox(_context.Languages, l => l.Title, l => l.Value)
                           .DropDownStyle(DropdownStyles.DropdownList)
                           .Width(250)
                           .Select(Model.Language)
                           .Name("UserProfile.Language")
                           .GetHtml()
                )
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_TimeZones">
                    @Html.Global("RES_TIMEZONE"):</label>
            </td>
            <td>
                @(Ajax.DnaFor().ComboBox(_context.TimeZones, z => z.Title, z => z.Value)
                           .DropDownStyle(DropdownStyles.DropdownList)
                           .Width(250)
                           .Select(Model.TimeZone)
                           .Name("UserProfile.TimeZone")
                           .GetHtml()
                )
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_Phone">
                    @Html.Global("RES_PHONE"):</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.Phone).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_Mobile">
                    @Html.Global("RES_MOBILE"):</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.Mobile).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_Country">
                    @Html.Global("RES_COUNTRY"):</label>
            </td>
            <td>
                @{
                    var dict = new Dictionary<string, RegionInfo>();

                    foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
                    {
                        var region = new RegionInfo(culture.LCID);

                        if (!dict.ContainsKey(region.TwoLetterISORegionName))
                        {
                            dict.Add(region.TwoLetterISORegionName, region);
                        }
                    }
                    var countries = dict.OrderBy(p => p.Value.NativeName).ToList();
                }
                @(Ajax.Dna().ComboBox("UserProfile.Country")
                                 .Items(items =>
                                 {
                                     for (int i = 0; i < countries.Count; i++)
                                     {
                                         items.AddValue(countries[i].Value.NativeName, countries[i].Key.ToString());
                                     }
                                 })
                                 .DropDownList()
                                 .Select(Model.Country)
                                 .GetHtml()
                )
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_State">
                    @Html.Global("RES_STATE"):</label>
            </td>
            <td>
                @(Ajax.DnaFor().TextBox(m => m.State)
                           .GetHtml()
                )
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_City">
                    @Html.Global("RES_CITY"):</label>
            </td>
            <td>
                @(Ajax.DnaFor().TextBox(m => m.City)
                           .GetHtml()
                )
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_ZipCode">
                    @Html.Global("RES_POSTCODE"):</label>
            </td>
            <td>
                @(Ajax.DnaFor().TextBox(m => m.ZipCode)
                           .GetHtml()
                )
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_Address">
                    @Html.Global("RES_ADDRESS"):</label>
            </td>
            <td>
                @(Ajax.DnaFor().TextBox(m => m.Address)
                           .Width(300)
                           .GetHtml()
                )
            </td>
        </tr>
    </table>
    </text>);
          views.Add(Html.Global("RES_CONTACTINFO")).Template(@<text>
    <table class="d-field-table" cellspacing="0px">
        <tr>
            <td>
                <label for="UserProfile_Blog">
                    @Html.Global("RES_BLOG"):</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.Blog).Width(300).IconImageUrl(Url.Content("~/content/images/icon_blog.png")).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_WebSite">
                    @Html.Global("RES_WEBSITE"):</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.WebSite).Width(300).IconImageUrl(Url.Content("~/content/images/icon_home.png")).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_Facebook">
                    Facebook:</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.Facebook).Width(300).IconImageUrl(Url.Content("~/content/images/icon_facebook_16.png")).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_Twitter">
                    Twitter:</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.Twitter).Width(300).IconImageUrl(Url.Content("~/content/images/icon_twitter_16.png")).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_Yahoo">
                    @Html.Global("RES_YAHOO"):</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.Yahoo).Width(300).IconImageUrl(Url.Content("~/content/images/icon_yahoo.png")).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_MSN">
                    @Html.Global("RES_MSN"):</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.MSN).Width(300).IconImageUrl(Url.Content("~/content/images/icon_msn.png")).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_LinkedIn">
                    LinkedIn:</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.LinkedIn).Width(300).IconImageUrl(Url.Content("~/content/images/icon_linkedin.gif")).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_GooglePlus">
                    Google+:</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.GooglePlus).Width(300).IconImageUrl(Url.Content("~/content/images/icon_google_plus.png")).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                <label for="UserProfile_Skype">
                    Skype:</label>
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.Skype).Width(300).IconImageUrl(Url.Content("~/content/images/icon_skype.png")).GetHtml()
            </td>
        </tr>
    </table>
    </text>);
          views.Add(Html.Global("RES_SIGNATURE"))
.Template(() =>
{
    Ajax.Dna().RichTextBox("UserProfile.Signature")
              .AllowHTMLEditing(false)
        //.Width(760)
              .Value(Model.Signature)
              .Render();
});
@*views.Add(Html.Global("RES_AVATAR"))
            .Template(@<text>
    <table cellspacing="0px" class="d-content">
        <tr>
            <td valign="top" align="center">
                @Html.Global("RES_AVATAR")
            </td>
        </tr>
        <tr>
            <td align="center">
                <img id="AvatarPreview" src="@(string.IsNullOrEmpty(Model["Avatar"].ToString()) ? Url.Content("~/content/images/no-avatar.gif") : Model["Avatar"].ToString())" alt="" style="width: 90px; height: 90px;" />
                @Html.Hidden("Avatar", Model["Avatar"].ToString())
            </td>
        </tr>
        <tr>
            <td align="center">
                @Ajax.Dna().Button("btnResetAvatar").LocText("RES_DELETE").Click("$('#Avatar').val('');$('#AvatarPreview').attr('src','" + Url.Content("~/content/images/no-avatar.gif") + "');").GetHtml()
            </td>
        </tr>
        <tr>
            <td style="height: 200px;" valign="top">
                @(
 Ajax.Dna().ImageFileListBox("AvatarListView", Url.Action("GetFiles", "WebFiles", new { Area = "", url = _context.ApplicationPath + "/webshared/home/images/avatars" }), "POST")
                        .Options(opts =>
                        {
                            opts.IsInlineMode = true;
                            opts.OnItemSelected = "$('#Avatar').val(ui.value);$('#AvatarPreview').attr('src',ui.value);";
                        })
                        .Width(780)
                        .Height(200).GetHtml()
                        )
            </td>
        </tr>
    </table>
    </text>);*@
      })
      .Render();

    <div style="margin-top: 10px; height: 40px; text-align: center;">
        @Ajax.Dna().Button("btnSubmit").Submit().LocText("RES_SAVE").ImageIcons(Url.Content("~/content/images/icon_save.gif")).GetHtml()
    </div>
}
@Html.StartupScripts()
